<style lang="scss">
  
</style>
<template>
  <div>
    <el-row :gutter="0">
      <el-carousel :interval="0" arrow="never" height="500px" type="card">
        <el-carousel-item v-for="(item,index) in dataimg" :key="index">
          <div class="grid-content">
            <el-col :md="12" :offset="6">
              <div>
                <img :src="item.src">
              </div>
            </el-col>
          </div>
        </el-carousel-item>
      </el-carousel>
    </el-row>
    <div style="margin-top:50px" >
        <el-form label-width="80px">
          <el-form-item label="文章：">
            <!-- <el-input type="textarea" v-model="title" :disabled="true" ></el-input> -->
            <div v-html="title"></div>
          </el-form-item>
          <el-form-item label="审核失败原因">
            <el-input type="textarea" v-model="reason"></el-input>
          </el-form-item>
        </el-form>
        <el-button type="success" @click="onCheckOk(1)">通过</el-button>
        <el-button type="danger" @click="onCheckOk(2)">不通过</el-button>
    </div>
  </div>
  
  
</template>

<script>
  export default {
    data() {
      return {
        id: '',
        title: "",
        dataimg: [],
        reason: ''
      }
    },
    computed: {
      documentClientHeight: {
        get () { return this.$store.state.common.documentClientHeight }
      },
      menuActiveName: {
        get () { return this.$store.state.common.menuActiveName },
        set (val) { this.$store.commit('common/updateMenuActiveName', val) }
      },
      mainTabs: {
        get () { return this.$store.state.common.mainTabs },
        set (val) { this.$store.commit('common/updateMainTabs', val) }
      },
      mainTabsActiveName: {
        get () { return this.$store.state.common.mainTabsActiveName },
        set (val) { this.$store.commit('common/updateMainTabsActiveName', val) }
      },
      siteContentViewHeight () {
        var height = this.documentClientHeight - 50 - 30 - 2
        if (this.$route.meta.isTab) {
          height -= 40
          return isURL(this.$route.meta.iframeUrl) ? { height: height + 'px' } : { minHeight: height + 'px' }
        }
        return { minHeight: height + 'px' }
      }
    },
    mounted() {
      this.id = this.$route.query.id.toString();
      this.init(this.id);
    },
    methods: {
      // tabs, 删除tab
      removeTabHandle (tabName) {
        this.mainTabs = this.mainTabs.filter(item => item.name !== tabName)
        if (this.mainTabs.length >= 1) {
          // 当前选中tab被删除
          if (tabName === this.mainTabsActiveName) {
            this.$router.push({ name: this.mainTabs[this.mainTabs.length - 1].name }, () => {
              this.mainTabsActiveName = this.$route.name
            })
          }
        } else {
          this.menuActiveName = ''
          this.$router.push({ name: 'home' })
        }
      },
      tabsCloseCurrentHandle () {
        this.removeTabHandle(this.mainTabsActiveName)
      },
      init(id) {
        this.$http({
            url: this.$http.adornUrl(`/biz/publishExperts/info/${id}`),
            method: 'post',
            data: this.$http.adornParams()
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.title = data.publishExperts.article;
              this.dataimg = data.publishExperts.images;
            } else {
              this.$message.error(data.msg)
            }
          })
      },
      onCheckOk(states) {
        var _This = this;
        if (this.reason == '' && states == 2) {
          this.$message.error('请填写审核失败原因');
          return;
        }

        this.$confirm(`确定当前操作?`, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.$http({
            url: this.$http.adornUrl(`/biz/publishExperts/auth/${this.id}?state=${states}&reason=${_This.reason}`),
            method: 'post',
            data: this.$http.adornParams()
          }).then(({data}) => {
            if (data && data.code === 0) {
              this.$message({
                message: '操作成功',
                type: 'success',
                duration: 1500,
                onClose: () => {
                  this.tabsCloseCurrentHandle();
                  this.$router.push({ path: '/biz-publishExperts' });
                }
              })
            } else {
              this.$message.error(data.msg)
            }
          })
        })
      }
    }
  }
</script>
